/*****************************************************************************/
/* Project:  COVID19 and Regime effect*/
/* Date: 2022.12.28 */
/* Author: Hyesong Ha */
/* consulting website:    */
*  https://blog.stata.com/2020/03/24/import-covid-19-data-from-johns-hopkins-university/
/*****************************************************************************/
*revised: 2023.01.31

clear all               //this command removes data, value labels, matrices, 
                        //scalars, saved results, etc from memory.
capture log close
cd "C:\Users\Hyesong\Dropbox\Stata_class\work"
run spost

log using  C19_Regime_excess_JPP_code.log, text replace

// #0
//program setup
*version 16.1
set linesize 100
matrix drop _all
set scheme s2color
set matsize 1000
set more off
* set mem 100m //Memory setup doesn't need to request for Stata13


*****
use covid19_1210_stringency_FH_trut_Disaster_v2, clear

keep code_c country_n ///
      infection_rate_1210 death_rate_1210 test_rate_1210 /// //DV1
	  infection_rate_mean death_rate_mean test_rate_mean /// //DV2
	  infection_rate_mean_new death_rate_mean_new test_rate_mean_new /// //DV3
	 FH_2group FreedomHouse2020 m_stringency std_confidence_gov765 confidence_gov765 /// //IV
	  pop_size_ln pop_dens_ln gdp_cap_ln  /// //control
	  disaster_n Total_Affected Total_Deaths // // disaster control

**codebook

codebook code_c country_n ///
       ///  infection_rate_1210 death_rate_1210 test_rate_1210 /// //DV1
	  infection_rate_mean death_rate_mean test_rate_mean /// //DV2
	  infection_rate_mean_new death_rate_mean_new test_rate_mean_new /// //DV3
	 FH_2group FreedomHouse2020 m_stringency std_confidence_gov765 /// confidence_gov765 /// //IV
	  pop_size_ln pop_dens_ln gdp_cap_ln  /// //control
	  disaster_n /// Total_Affected Total_Deaths /// // disaster control
	  , compact
	  
*save data as excel	  
// export excel covid19_1210_stringency_FH_trut_Disaster_v2,  first(variables) nol replace  
************************************************************************	  
**Table 1  Descriptive Statistics
sum   /// infection_rate_1210 death_rate_1210 test_rate_1210 /// //DV1
	  infection_rate_mean death_rate_mean test_rate_mean /// //DV2
	 /// infection_rate_mean_new death_rate_mean_new test_rate_mean_new /// //DV3
	 FH_2group FreedomHouse2020 m_stringency std_confidence_gov765 /// confidence_gov765 /// //IV
	  pop_size_ln pop_dens_ln gdp_cap_ln  /// //control
	  disaster_n // Total_Affected Total_Deaths // // disaster control

	  
note: excess death will be added later 
	
**test: multi-colinearity

 collin   FreedomHouse2020 m_stringency std_confidence_gov765  /// //IV
	  pop_size_ln pop_dens_ln gdp_cap_ln  /// //control
	  disaster_n   // Total_Affected Total_Deaths  // disaster control

/*

                        SQRT                   R-
  Variable      VIF     VIF    Tolerance    Squared
----------------------------------------------------
FreedomHouse2020      1.81    1.34    0.5538      0.4462
m_stringency      1.12    1.06    0.8901      0.1099
std_confidence_gov765      1.29    1.14    0.7737      0.2263
pop_size_ln      1.38    1.17    0.7266      0.2734
pop_dens_ln      1.06    1.03    0.9414      0.0586
gdp_cap_ln      1.95    1.40    0.5130      0.4870
disaster_n      1.85    1.36    0.5405      0.4595
----------------------------------------------------
  Mean VIF      1.49
*/


**Table 2 Correleation

pwcorr /// infection_rate_1210 death_rate_1210 test_rate_1210 /// //DV1
	  infection_rate_mean death_rate_mean test_rate_mean /// //DV2
	 /// infection_rate_mean_new death_rate_mean_new test_rate_mean_new /// //DV3
	 FreedomHouse2020 m_stringency std_confidence_gov765 /// confidence_gov765 /// //IV
	  pop_size_ln pop_dens_ln gdp_cap_ln  /// //control
	  disaster_n, star(0.05)


/***** table 3 *****/
tabstat /// infection_rate_1210 death_rate_1210 test_rate_1210 /// //DV1
	  infection_rate_mean death_rate_mean test_rate_mean /// //DV2
	 /// infection_rate_mean_new death_rate_mean_new test_rate_mean_new /// //DV3
      FreedomHouse2020 m_stringency std_confidence_gov765 /// confidence_gov765 /// //IV
	  pop_size_ln pop_dens_ln gdp_cap_ln  /// //control
	  disaster_n /// Total_Affected Total_Deaths /// // disaster control
   , by(FH_2group)  nototal format  col(var) stat(mean N)  // col(stat)

 * Two independent sample t-test: DV ( Interval & normal)
 ttest infection_rate_mean,  by(FH_2group)  //*
 ttest death_rate_mean,  by(FH_2group)    //*
 ttest test_rate_mean, by(FH_2group)     // not sig
  ttest  FreedomHouse2020 ,  by(FH_2group)  // *
 ttest m_stringency ,  by(FH_2group)   //  not sig
 ttest std_confidence_gov765, by(FH_2group) //   *
 
 ttest  pop_size_ln ,  by(FH_2group)  //*
 ttest pop_dens_ln ,  by(FH_2group)  // not sig
 ttest gdp_cap_ln ,  by(FH_2group)   // *
 ttest  disaster_n, by(FH_2group)   // *


***********************************************************
**Appendix4
** graphs: 2goup
***********************************************************

************************************************************   
* covid19 vs. FreedomHouse2020 by(FH_2group)
twoway (scatter infection_rate_mean FreedomHouse2020 , by(FH_2group)) ///
	   || (lfit infection_rate_mean FreedomHouse2020, sort  by(FH_2group) lcolor(red) )  

twoway (scatter death_rate_mean FreedomHouse2020 , by(FH_2group)) ///
	   || (lfit death_rate_mean FreedomHouse2020, sort  by(FH_2group) lcolor(red) )  

twoway (scatter test_rate_mean FreedomHouse2020 , by(FH_2group)) ///
	   || (lfit test_rate_mean FreedomHouse2020, sort  by(FH_2group) lcolor(red) )  
	   
//correlation and fitted line: mean cases
regress   infection_rate_mean FreedomHouse2020  if FH_2group==0	
correlate    infection_rate_mean FreedomHouse2020 if FH_2group==0

* Y=3457.12-28.86*X, slope P-value=0.481; corr=-0.085

regress infection_rate_mean FreedomHouse2020  if FH_2group==1	
correlate    infection_rate_mean FreedomHouse2020 if FH_2group==1	 
  
 * Y=-2595.80+86.2*X, slope P-value=0.018; corr=0.248
  
//correlation and fitted line: mean deaths
regress death_rate_mean FreedomHouse2020  if FH_2group==0	
correlate   death_rate_mean FreedomHouse2020 if FH_2group==0

* Y=32.39+0.040*X, slope P-value=0.913; corr=0.013

regress death_rate_mean FreedomHouse2020  if FH_2group==1	
correlate   death_rate_mean FreedomHouse2020 if FH_2group==1	

 * Y=-74.43+2.94*X, slope P-value=0.14; corr=0.161  

//correlation and fitted line: mean test
regress test_rate_mean FreedomHouse2020  if FH_2group==0	
correlate   test_rate_mean FreedomHouse2020 if FH_2group==0

* Y=193.06-3.29*X, slope P-value=0.049; corr=-0.340

regress test_rate_mean FreedomHouse2020  if FH_2group==1	
correlate   test_rate_mean FreedomHouse2020 if FH_2group==1	

 * Y=-315.9+5.19*X, slope P-value=0.000; corr=0.432 
 

***************************************************
** Appendix 3
*******************************************************
**recode std_confidence_gov765 into 2 trust group
sum std_confidence_gov765, detail

recode std_confidence_gov765 (.0000101/37.22024 = 0 "Low Trust") (37.220241/101 = 1  "Hign Trust") ///
             (missing = .), gen (trust) // label("Government Trust")
label var trust "Government Trust(std)"
order std_confidence_gov765 trust, last
tab trust


**Graph 1: Infection vs. Democracy
// w/o trust
twoway  (scatter  infection_rate_mean FreedomHouse2020  ///
        , mlabel(code_c)  msymbol(oh) sort(FreedomHouse2020)) ///
        (lfit infection_rate_mean  FreedomHouse2020)  ///
		, xtitle (Democracy level) ytitle(average Infection per Million) ///
		legend(off) 
		
graph save infection_demo_all.gph, replace

// w/ democracy		
twoway  (scatter infection_rate_mean FreedomHouse2020 if trust ==0 ///
         , mlabel(code_c)  msymbol(oh) sort(FreedomHouse2020)) /// legend(label("Low Democarcy")) 
	   	(scatter infection_rate_mean FreedomHouse2020 if trust ==1 ///
		, mlabel(code_c)  msymbol (dh) sort(FreedomHouse2020)) ///  legend(label("High Democarcy")) 
		 (lfit infection_rate_mean FreedomHouse2020 if trust ==0, msymbol(dash) sort(FreedomHouse2020)) ///
	    (lfit infection_rate_mean FreedomHouse2020 if trust ==1, msymbol(line) sort(FreedomHouse2020)) ///
		, pcycle(2) xtitle (Democracy Level) ytitle(average Infection per Million) ///
		legend (label(1 "Low Trust") label(2 "High Trust")) //
		
		
graph save infection_Demo_byTrust.gph, replace		

//combine
graph combine 	infection_demo_all.gph  infection_Demo_byTrust.gph  ///
               , altshrink cols(1) iscale(1) 
			   
graph save gp1_Infection_demo_trust.gph, replace

**Graph 2: Deaths vs. Democracy
// w/o trust
twoway  (scatter  death_rate_mean FreedomHouse2020  ///
        , mlabel(code_c)  msymbol(oh) sort(FreedomHouse2020)) ///
        (lfit death_rate_mean  FreedomHouse2020)  ///
		, xtitle (Democracy level) ytitle(average Deaths per Million) ///
		legend(off) 
		
graph save Death_demo_all.gph, replace

// w/ democracy		
twoway  (scatter death_rate_mean FreedomHouse2020 if trust ==0 ///
         , mlabel(code_c)  msymbol(oh) sort(FreedomHouse2020)) /// legend(label("Low Democarcy")) 
	   	(scatter death_rate_mean FreedomHouse2020 if trust ==1 ///
		, mlabel(code_c)  msymbol (dh) sort(FreedomHouse2020)) ///  legend(label("High Democarcy")) 
		 (lfit death_rate_mean FreedomHouse2020 if trust ==0, msymbol(dash) sort(FreedomHouse2020)) ///
	    (lfit death_rate_mean FreedomHouse2020 if trust ==1, msymbol(line) sort(FreedomHouse2020)) ///
		, pcycle(2) xtitle (Democracy Level) ytitle(average Deaths per Million) ///
		legend (label(1 "Low Trust") label(2 "High Trust")) //
		
		
graph save Death_Demo_byTrust.gph, replace		

//combine
graph combine 	Death_demo_all.gph  Death_Demo_byTrust.gph  ///
               , altshrink cols(1) iscale(1) 
			   
graph save gp2_Death_demo_trust.gph, replace


**Graph 3: test vs. Democracy
// w/o trust
twoway  (scatter  test_rate_mean FreedomHouse2020  ///
        , mlabel(code_c)  msymbol(oh) sort(FreedomHouse2020)) ///
        (lfit test_rate_mean  FreedomHouse2020)  ///
		, xtitle (Democracy level) ytitle(average Test per Thousand) ///
		legend(off) 
		
graph save test_demo_all.gph, replace

// w/ democracy		
twoway  (scatter test_rate_mean FreedomHouse2020 if trust ==0 ///
         , mlabel(code_c)  msymbol(oh) sort(FreedomHouse2020)) /// legend(label("Low Democarcy")) 
	   	(scatter test_rate_mean FreedomHouse2020 if trust ==1 ///
		, mlabel(code_c)  msymbol (dh) sort(FreedomHouse2020)) ///  legend(label("High Democarcy")) 
		 (lfit test_rate_mean FreedomHouse2020 if trust ==0, msymbol(dash) sort(FreedomHouse2020)) ///
	    (lfit test_rate_mean FreedomHouse2020 if trust ==1, msymbol(line) sort(FreedomHouse2020)) ///
		, pcycle(2) xtitle (Democracy Level) ytitle(average Test per Thousand) ///
		legend (label(1 "Low Trust") label(2 "High Trust")) //
		
		
graph save test_Demo_byTrust.gph, replace		

//combine
graph combine 	test_demo_all.gph  test_Demo_byTrust.gph  ///
               , altshrink cols(1) iscale(1) 
			   
graph save gp3_test_demo_trust.gph, replace


**************************************************************************
***Regression Analyses***********************************************
***********************************************************************
****Table 5. Results from Hierarchical Model with Binary Moderators

		// Total : infection_rate
	eststo clear

	eststo model1: qui   reg  infection_rate_mean   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg infection_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg infection_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FH_2group ///
		 c.m_stringency#i.FH_2group ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg infection_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     trust   /// //FH_2group ///
		 c.m_stringency#i.trust ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg infection_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FH_2group ///
		 c.m_stringency#i.FH_2group ///
	     trust   /// //FH_2group ///
		 c.m_stringency#i.trust ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  

	// Total : death_rate
	eststo clear

	eststo model1: qui   reg  death_rate_mean   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg death_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg death_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FH_2group ///
		 c.m_stringency#i.FH_2group ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg death_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     trust   /// //FH_2group ///
		 c.m_stringency#i.trust ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg death_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FH_2group ///
		 c.m_stringency#i.FH_2group ///
	     trust   /// //FH_2group ///
		 c.m_stringency#i.trust ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  

	


	// Total : test_rate
	eststo clear

	eststo model1: qui   reg  test_rate_mean   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg test_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg test_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FH_2group ///
		 c.m_stringency#i.FH_2group ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg test_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     trust   /// //FH_2group ///
		 c.m_stringency#i.trust ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg test_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FH_2group ///
		 c.m_stringency#i.FH_2group ///
	     trust   /// //FH_2group ///
		 c.m_stringency#i.trust ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  
	



******************************************************************
**Appendix 5. Results from Hierarchical Model with continuous Moderators
***********************************************************************	
	
	// Total : infection_rate
	eststo clear

	eststo model1: qui   reg  infection_rate_mean   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg infection_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg infection_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg infection_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg infection_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  
	
	// Total : death_rate  
	eststo clear

	eststo model1: qui   reg  death_rate_mean   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg death_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg death_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg death_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg death_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  


	// Total : test_rate
	eststo clear

	eststo model1: qui   reg  test_rate_mean   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg test_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg test_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg test_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg test_rate_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  


********************************************************************************
**Appendix 6. Results from Hierarchical Model with continuous Moderators for health outcomes newly added 
******************************************************************
	// Total : infection_rate_mean_new
	eststo clear

	eststo model1: qui   reg  infection_rate_mean_new   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg infection_rate_mean_new  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg infection_rate_mean_new  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg infection_rate_mean_new  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg infection_rate_mean_new ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  


	// Total : death_rate_mean_new  
	eststo clear

	eststo model1: qui   reg  death_rate_mean_new    ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg death_rate_mean_new   ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg death_rate_mean_new   ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg death_rate_mean_new   ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg death_rate_mean_new   ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  
	
	// Total : test_rate_mean_new 
	eststo clear

	eststo model1: qui   reg  test_rate_mean_new   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg test_rate_mean_new   ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg test_rate_mean_new  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg test_rate_mean_new   ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg test_rate_mean_new   ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic 


******************************************************************************
**JPP R&R additional work
**Analysis with excess_rate as new DV1
*******************************************************************************
use C19_regime_excess_2024.01.29, clear

*save data as excel
//export excel C19_regime_excess,  first(variables) nol replace  

* excess death per 1 M
gen excess_m=excess_mean/10
drop excess_mean
rename excess_m excess_mean
label var excess_mean "ExcessDeath per 1M"
**Table1 Descriptive Statistics

codebook code_c country_n ///
      infection_rate_1210 death_rate_1210 test_rate_1210 /// //DV1
	  infection_rate_mean death_rate_mean test_rate_mean /// //DV2
	  infection_rate_mean_new death_rate_mean_new test_rate_mean_new /// //DV3
	   excess_mean  ///  //DV4  excess death per 1,000,000  excess_low excess_high 
	 FH_2group FreedomHouse2020 m_stringency std_confidence_gov765 confidence_gov765 /// //IV
	 	  pop_size_ln pop_dens_ln gdp_cap_ln  /// //control
	  disaster_n Total_Affected Total_Deaths /// // disaster control
	  , compact
	  
**Table1
sum infection_rate_1210 death_rate_1210 test_rate_1210 /// //DV1
	  infection_rate_mean death_rate_mean test_rate_mean /// //DV2
	  infection_rate_mean_new death_rate_mean_new test_rate_mean_new /// //DV3
	  excess_mean  ///  //DV4  excess death per 100,0000  excess_low excess_high
	 FH_2group FreedomHouse2020 m_stringency std_confidence_gov765 confidence_gov765 /// //IV
	  pop_size_ln pop_dens_ln gdp_cap_ln  /// //control
	  disaster_n Total_Affected Total_Deaths // // disaster control
	  


**recode std_confidence_gov765 into 2 trust group
sum std_confidence_gov765, detail

recode std_confidence_gov765 (.0000101/37.22024 = 0 "Low Trust") (37.220241/101 = 1  "Hign Trust") ///
             (missing = .), gen (trust) // label("Government Trust")
label var trust "Government Trust(std)"
order std_confidence_gov765 trust, last
tab trust




*************************************************************************
**Appendix 7. Results from Hierarchical Model with continuous Moderators for Excess Mortality
************************************************************************

// Total : excess_mean  

	eststo clear

	eststo model1: qui   reg  excess_mean   ///  //DV
		/// stringency_m  std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
	
	eststo model2: qui   reg excess_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	   ///  if FH_2group==1 ///
		  , vce(robust)  
		  
	  
	 eststo model3_MO1: qui  	 reg excess_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
		  , vce(robust)  
		  
	eststo model4_MO2: qui 	reg excess_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 
		  
	eststo model5_MO12: qui   reg excess_mean  ///  //DV
		 m_stringency  /// std_confidence_gov765 /// //IV2  stringency_max 
		 pop_size_ln pop_dens_ln gdp_cap_ln  /// // control  	equality 
		 disaster_n ///   // Bio disaster controlled
		 FreedomHouse2020 ///
		 c.m_stringency#c.FreedomHouse2020 ///
	     std_confidence_gov765   /// //FH_2group ///
		 c.m_stringency#c.std_confidence_gov765 ///
		  , vce(robust) 	  
		  
	
	esttab * , r2 ar2 aic bic  	
	
	
log close
exit
